﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ParamArrayTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("{0:F1}",Average(19.2,18.2,29)); //{0:F1}表示小数点后面有1位小数

            Console.ReadKey();
        }//end Main

        public static double Average(params double[] numbers)  //params  游长变元表
        {
            double total = 0;

            foreach (double number in numbers)
            {
                total += number;
            }//end for

            return total / numbers.Length;
        }//end method Average 
    }
}
